package com.swz.dcrm.util;

import android.content.Context;
import android.graphics.Rect;

import android.view.View;

import androidx.recyclerview.widget.RecyclerView;

/**
 * @author xh on 2019/4/16
 */
public class CustomDecoration extends RecyclerView.ItemDecoration {
    private int left;
    private int right;
    private int top;
    private int bottom;


    public CustomDecoration(Context context,int top, int bottom, int left, int right) {
        this.top = Tool.dip2px(context,top);
        this.bottom=Tool.dip2px(context,bottom);
        this.left=Tool.dip2px(context,left);
        this.right=Tool.dip2px(context,right);
    }

    @Override
    public void getItemOffsets(Rect outRect, View view,
                               RecyclerView parent, RecyclerView.State state) {

        outRect.bottom = bottom;
        outRect.top = top;
        outRect.left = left;
        outRect.right = right;

        if (parent.getChildPosition(view) == 0&&top==0){
            outRect.top = Tool.dip2px(view.getContext(),10);
        }


       }


}
